package com.whynot.frame.stream.mq.receive;

import com.whynot.frame.stream.mq.config.MessageMQ;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;

import java.util.Map;

/**
 * 描    述:接收消息
 * 创建时间: 2018/12/21
 */
@EnableBinding(MessageMQ.class)
public class ReceiveMQ {
    int count = 0;
    @StreamListener(MessageMQ.WECHAT_SEND_INPUT)
    public void handler(Map<String, Object> msg) throws Exception {
        System.out.println(msg);
        count++;
        /*System.out.println("计数器"+count);
        if(count>10){
            throw new Exception("ceshi");
        }*/
    }

    /**
     * 消息消费失败的降级处理逻辑
     *
     * @param message
     */
    /*@ServiceActivator(inputChannel = "wx:send-stream.group_send.errors")
    public void error(Message<?> message) {
        System.out.println("Message consumer failed, call fallback!"+message);
    }*/
}